home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug106 / system.c < prev    next >
Text File  |  1984-06-14  |  3KB  |  139 lines

  1. /*    system definitions
  2. **
  3. **    Version 1.2    07-Aug-80
  4. */
  5.  
  6. #define    ASCII_DATE    0x20BF            /* ASCII date */    
  7. #define CODED_DATE    ASCII_DATE+9        /* coded date */
  8. #define    TICCNT        0x201B            /* 2ms counter */
  9. #define    UIVEC        0x201F            /* user vector */
  10.  
  11. /*    BDOS addresses  */
  12.  
  13. #define    CBOOT        0x1800
  14. #define    BIOS        0x2280
  15. #define    BASE        0x4200
  16. #define    WBOOT        BASE
  17. #define    IOBYT        BASE+3
  18. #define BDOS        BASE+5
  19. #define MEM_SIZE        BASE+6
  20.  
  21. #define    FCB        BASE+92
  22. #define    FCBDN        FCB+0        /* disk name */
  23. #define    FCBFN        FCB+1        /* file name */
  24. #define    FCBFT        FCB+9        /* file type */
  25. #define    FCBRL        FCB+12        /* reel number */
  26. #define    FCBST        FCB+13        /* status (date,flags) */
  27. #define    FCBRC        FCB+15        /* record count */
  28. #define    FCBCR        FCB+32        /* next record number */
  29. #define    FCBLN        FCB+33        /* FCB length */
  30.  
  31. #define    BUFF        BASE+128
  32. #define    TPA        BASE+0x100
  33.  
  34. /*    BDOS system calls */
  35.  
  36. #define    SYS_RESET    0
  37. #define    RD_CON        1
  38. #define    WR_CON        2
  39. #define    RD_RDR        3
  40. #define    WR_PUN        4
  41. #define    WR_LST        5
  42. #define    INTER_IO    7
  43. #define    ALTER_IO    8
  44. #define    WR_BUFFER    9
  45. #define    RD_BUFFER    10
  46. #define    CHECK_STATUS    11
  47. #define    RESET_DISK    13
  48. #define    SELECT_DISK    14
  49. #define    OPEN_FILE    15
  50. #define    CLOSE_FILE    16
  51. #define    SEARCH_FIRST    17
  52. #define    SEARCH_NEXT    18
  53. #define    DELETE_FILE    19
  54. #define    RD_RECORD    20
  55. #define    WR_RECORD    21
  56. #define    CREATE_FILE    22
  57. #define    RENAME_FILE    23
  58. #define    INTER_LOGIN    24
  59. #define    INTER_DISK    25
  60. #define    SET_DMA        26
  61. #define    INTER_ALLOC    27
  62. /*
  63.         Function Summary
  64.         ----------------
  65.  
  66. charcnt(bufpntr)
  67.  
  68.     returns the number of characters in the file at bufpntr.
  69.     file must be in a continuous block of RAM.
  70.  
  71. linecnt(bufpntr)
  72.  
  73.     returns the number of lines in the file at bufpntr.
  74.     file must be in a continuous block of RAM.
  75.  
  76. ntoi(number,base)
  77.  
  78.     converts ASCII digits to an integer using any base
  79.     except split octal (see otoi). white space may preceed
  80.     the ASCII string which must end with '\0' after the
  81.     final digit.
  82.  
  83. otoi(number)
  84.  
  85.     converts ASCII digits representing a split octal
  86.     number in the format xxx.xxx{a} to an integer. white
  87.     space may preceed the ASCII string which must be
  88.     7 characters long (3 chars,'.',3 chars). any following
  89.     characters are ignored (ie. does not require '\0' as
  90.     final delimiter).
  91.  
  92. wordcnt(bufpntr)
  93.  
  94.     returns the number of words in the file at bufpntr.
  95.     file must be in a continuous block of RAM. note that
  96.     '\n' is handled explicitly as CRLF to avoid false
  97.     triggering of the word count on an empty line.
  98. */
  99.  
  100. #define    LF    10
  101. #define    CR    13
  102. #define    EOF    26
  103. #define    NO    0
  104. #define    YES    -1
  105.  
  106. charcnt(bufpntr)
  107. char *bufpntr;
  108. {
  109.     int nc;
  110.     char c;
  111.  
  112.     nc = 0;
  113.     while((c = *bufpntr++) != EOF) nc += 1;
  114.     return nc;
  115. }
  116.  
  117. linecnt(bufpntr)
  118. char *bufpntr;
  119. {
  120.     int nc;
  121.     char c;
  122.  
  123.     nc = 0;
  124.     while((c = *bufpntr++) != EOF) {
  125.        if (c == '\n') nc += 1;
  126.     }
  127.     return nc;
  128. }
  129.  
  130. ntoi(n,b)
  131. char *n;
  132. int b;
  133. {
  134.     int val,sign;
  135.     char c;
  136.  
  137.     val=0; sign=1;
  138.     while ((c = *n) == '\t' || c == ' ') ++n;
  139.     if (c == '-')